package com.yesido.springcloud.feign.service;

import com.yesido.pojo.User;
import feign.hystrix.FallbackFactory;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author yesido
 * @description 服务降级的工厂类
 * @date 2023-06-06 22:06
 * @Version 8.3
 */
@Configuration
public class ClientServiceFallbackFactory implements FallbackFactory {

    @Override
    public FeignService create(Throwable throwable) {
        return new FeignService() {
            @Override
            public User getUserById(int id) {
                return new User().
                        setUserName("null").
                        setDbNames("query is null ->,mysql query is null--客户端提供了降级信息，这个服务已经被关闭");
            }
            @Override
            public List<User> findAllUsers() {
                return null;
            }

            @Override
            public int addUser(User user) {
                return 0;
            }
        };
    }
}
